// components/changsha/changsha.js



Component({
  lifetimes: {
    created: function () {
      var QQMapWX = require('../../libs/qqmap-wx-jssdk');
      var qqmapsdk;
      this.mapCtx = wx.createMapContext('myMap')

    }

  },


  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    count: 1,
    longitude: 112.682482,
    latitude: 28.05964,
    markers: [{
      id: 1,
      longitude: 112.682482,
      latitude: 28.05964,
      name: '腾讯',
      alpha: 0.75,
      width: 15,
      height: 25

    },
    {
      id: 2,
      longitude: 112.682482,
      latitude: 28.05964,
      name: '腾讯',
      width: 15,
      height: 25,
      callout: {

        content: "2:30，陈某自驾从上海经高速来长\n当日16:05-17:45，抵达长韶娄高速花明楼服务区停留\n期间在服务区上洗手间",
        borderRadius: 15,
        padding: 10,
        display: 'BYCLICK',
        fontSize: 15,
        textAlign: "center",
        anchorX: -10
      },
    },
    {
      id: 3,
      longitude: 112.351916,
      latitude: 27.978156,
      name: '终点',
      width: 15,
      height: 25,
      callout: {
        content: "18:05，经长韶娄高速灰汤收费站下高速\n后至宁乡市集中隔离酒店，纳入集中隔离管控。",
        borderRadius: 15,
        padding: 10,
        display: 'BYCLICK',
        fontSize: 15,
        textAlign: "center",
        anchorX: -10
      },
    },
    ],

    polyline: [{
      points: [{
        longitude: 112.682482,
        latitude: 28.05964
      },
      {
        longitude: 112.677407,
        latitude: 28.059345
      },
      {
        longitude: 112.670266,
        latitude: 28.058213
      },
      {
        longitude: 112.659782,
        latitude: 28.055647
      },
      {
        longitude: 112.655704,
        latitude: 28.054994
      },
      {
        longitude: 112.650009,
        latitude: 28.055424
      },
      {
        longitude: 112.645613,
        latitude: 28.056065
      },
      {
        longitude: 112.639867,
        latitude: 28.05638
      },
      {
        longitude: 112.621047,
        latitude: 28.055137
      },
      {
        longitude: 112.617847,
        latitude: 28.054297
      },
      {
        longitude: 112.605917,
        latitude: 28.048113
      },
      {
        longitude: 112.594413,
        latitude: 28.042169
      },
      {
        longitude: 112.580184,
        latitude: 28.037706
      },
      {
        longitude: 112.565667,
        latitude: 28.033529
      },
      {
        longitude: 112.55053,
        latitude: 28.029017
      },
      {
        longitude: 112.546595,
        latitude: 28.027359
      },
      {
        longitude: 112.540613,
        latitude: 28.023293
      },
      {
        longitude: 112.533911,
        latitude: 28.018367
      },
      {
        longitude: 112.53021,
        latitude: 28.015624
      },
      {
        longitude: 112.529348,
        latitude: 28.01529
      },
      {
        longitude: 112.526474,
        latitude: 28.015242
      },
      {
        longitude: 112.521569,
        latitude: 28.016533
      },
      {
        longitude: 112.519647,
        latitude: 28.016358
      },
      {
        longitude: 112.516862,
        latitude: 28.015114
      },
      {
        longitude: 112.51388,
        latitude: 28.013328
      },
      {
        longitude: 112.50964,
        latitude: 28.012005
      },
      {
        longitude: 112.508328,
        latitude: 28.011423
      },
      {
        longitude: 112.506424,
        latitude: 28.009924
      },
      {
        longitude: 112.503514,
        latitude: 28.007325
      },
      {
        longitude: 112.501843,
        latitude: 28.006575
      },
      {
        longitude: 112.502579,
        latitude: 28.006822
      },
      {
        longitude: 112.50098,
        latitude: 28.006376
      },
      {
        longitude: 112.50098,
        latitude: 28.006376
      },
      {
        longitude: 112.497045,
        latitude: 28.006663
      },
      {
        longitude: 112.494494,
        latitude: 28.00679
      },
      {
        longitude: 112.491152,
        latitude: 28.006152
      },
      {
        longitude: 112.488026,
        latitude: 28.004318
      },
      {
        longitude: 112.481073,
        latitude: 27.999917
      },
      {
        longitude: 112.476887,
        latitude: 27.997732
      },
      {
        longitude: 112.473581,
        latitude: 27.997317
      },
      {
        longitude: 112.470904,
        latitude: 27.997708
      },
      {
        longitude: 112.468461,
        latitude: 27.998362
      },
      {
        longitude: 112.466072,
        latitude: 27.998689
      },

      {
        longitude: 112.46282,
        latitude: 27.998282
      },
      {
        longitude: 112.456766,
        latitude: 27.996369
      },
      {
        longitude: 112.452795,
        latitude: 27.995141
      },
      {
        longitude: 112.448932,
        latitude: 27.994503
      },
      {
        longitude: 112.442572,
        latitude: 27.994192
      },

      {
        longitude: 112.436823,
        latitude: 27.992884
      },
      {
        longitude: 112.429978,
        latitude: 27.991194
      },
      {
        longitude: 112.422827,
        latitude: 27.989503
      },
      {
        longitude: 112.41379,
        latitude: 27.987286
      },
      {
        longitude: 112.408239,
        latitude: 27.985978
      },
      {
        longitude: 112.402274,
        latitude: 27.984989
      },
      {
        longitude: 112.397836,
        latitude: 27.98459
      },
      {
        longitude: 112.391117,
        latitude: 27.984702
      },
      {
        longitude: 112.385511,
        latitude: 27.985053
      },
      {
        longitude: 112.383481,
        latitude: 27.985005
      },

      {
        longitude: 112.382098,
        latitude: 27.984686
      },
      {
        longitude: 112.381164,
        latitude: 27.984559
      },
      {
        longitude: 112.376852,
        latitude: 27.98223
      },
      {
        longitude: 112.375361,
        latitude: 27.980715
      },
      {
        longitude: 112.373555,
        latitude: 27.978905
      },
      {
        longitude: 112.371183,
        latitude: 27.977469
      },
      {
        longitude: 112.367572,
        latitude: 27.976432
      },
      {
        longitude: 112.353029,
        latitude: 27.975371
      },
      {
        longitude: 112.351916,
        latitude: 27.978156
      },
      ],
      width: 4,
      color: "#3875FF",
      borderColor: "#38a9FF",
      borderWidth: 2



    }]

  },

  /**
   * 组件的方法列表
   */

  methods: {


    moveAlong: function (e) {
      console.log(1)

      this.mapCtx.moveAlong({
        markerId: 1,
        path: this.data.polyline[0].points,
        duration: 3000,
        autoRotate: false
      })


    },
    showInfo1: function (e) {
      if (this.data.count < 2)
        return
      console.log("上一条" + this.data.count)
      this.setData({
        count: this.data.count - 1,
      })
      this.setData({
        ['markers[' + this.data.count + '].callout.display']: 'BYCLICK',
      })
      var temp = this.data.count - 1
      this.setData({
        ['markers[' + temp + '].callout.display']: 'ALWAYS',
      })


    },




    showInfo: function (e) {
      if (this.data.count > 2)
        return;
      console.log("下一条" + this.data.count)
      if (this.data.count > 1) {
        var temp = this.data.count - 1
        this.setData({
          ['markers[' + temp + '].callout.display']: 'BYCLICK',
        })
      }


      this.setData({
        ['markers[' + this.data.count + '].callout.display']: 'ALWAYS',
        count: this.data.count + 1
      })

    },





  }
})
